-
Couldn't load subscription status.
- Fork 7
BRND Booking #313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
BRND Booking #313
Conversation
3b9835f to
e2b4b67
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, looks good.
There are a few issues I think you should handle.
| ], | ||
| 'api_auth_key' => [ | ||
| 'type' => 'string', | ||
| 'exposeValue' => true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should hide this value, otherwise everybody in the admin can see the value.
| 'exposeValue' => true, | |
| 'exposeValue' => false, |
It will still be possible to set the value, it will just not be visible in the admin after being set.
|
|
||
| $bookings = $this->apiClient->getInfomonitorBookingsDetails($feedSource, $sportCenterId); | ||
|
|
||
| $result['bookings'] = array_map([$this, 'parseBrndBooking'], $bookings); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to filter out entries that do not meet some minimum requirements (startTime, endTime, activity, ?)
Otherwise, you can end up with slides that display broken data.
I would replace array_map with array_reduce and add some validation checks and ignore broken entries.
| $startDateTime = null; | ||
| if (!empty($booking['dato']) && isset($booking['starttid']) && is_string($booking['starttid'])) { | ||
| // Trim starttid to 6 digits after dot for microseconds | ||
| $starttid = preg_replace('/\.(\d{6})\d+$/', '.$1', $booking['starttid']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace danish variable name with english.
Maybe: $startTimeString
| // Parse end time | ||
| $endDateTime = null; | ||
| if (!empty($booking['dato']) && isset($booking['sluttid']) && is_string($booking['sluttid'])) { | ||
| $sluttid = preg_replace('/\.(\d{6})\d+$/', '.$1', $booking['sluttid']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace danish variable name with english.
Maybe: $endTimeString
| $starttid = preg_replace('/\.(\d{6})\d+$/', '.$1', $booking['starttid']); | ||
| $dateOnly = substr($booking['dato'], 0, 10); | ||
| $dateTimeString = $dateOnly.' '.$starttid; | ||
| $startDateTime = \DateTimeImmutable::createFromFormat('m/d/Y H:i:s.u', $dateTimeString); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if this throws an exception or returns false?
https://www.php.net/manual/en/datetime.createfromformat.php
| $sluttid = preg_replace('/\.(\d{6})\d+$/', '.$1', $booking['sluttid']); | ||
| $dateOnly = substr($booking['dato'], 0, 10); | ||
| $dateTimeString = $dateOnly.' '.$sluttid; | ||
| $endDateTime = \DateTimeImmutable::createFromFormat('m/d/Y H:i:s.u', $dateTimeString); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if this throws an exception or returns false?
https://www.php.net/manual/en/datetime.createfromformat.php
| ]; | ||
| } | ||
|
|
||
| public function getData(Feed $feed): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure this function does not throw an exception.
It should always return $result, so the client does not have to handle the exceptions.
Link to ticket
Fixes #309
Description
Add BRND Booking feed type